package com.me.model.viewmodel;

import com.me.model.Orderitem;

import java.math.BigDecimal;
import java.util.Collection;

public class CartViewModel {
	private Collection<Orderitem> ois;
	private float price;

	public Collection<Orderitem> getOis() {
		return ois;
	}

	public void setOis(Collection<Orderitem> ois) {
		this.ois = ois;
		BigDecimal price = BigDecimal.valueOf(0);
		for (Orderitem o: ois) {
			price = price.add(o.getGoods().getDPrice().multiply(BigDecimal.valueOf(o.getAmount())));
		}
		this.price = price.floatValue();
	}

	public float getPrice() {
		return price;
	}
}
